package com.shizhefei.mvc;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

class NetUtil {
    static NetworkInfo getActiveNetworkInfo(Context context) {
        try {
            ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
            return cm.getActiveNetworkInfo();
        } catch (Exception e) {
            return null;
        }
    }

    static boolean isNetworkAvailable(Context context) {
        NetworkInfo info = getActiveNetworkInfo(context);
        return null != info && info.isAvailable();
    }


}
